﻿//--------抓取经营单位-----------


var casper = require('casper').create();
var companyName = casper.cli.get('companyName');
casper.start('http://www.haiguan.info/OnLineSearch/Gateway/weixin/weixinCompanyInfo.html');

casper.then(function () {
    var cookies = this.page.cookies;
    var checkcode = cookies[0].value;
    this.evaluate(function (company, code) {
        document.querySelector('input[id="companyName"]').setAttribute('value', company);
        document.querySelector('input[id="verifyCode"]').setAttribute('value', code);
    }, companyName, checkcode);
    this.click('#search');
});

casper.waitForSelector("table", function () {
    console.log(this.getHTML());
});

casper.run();